package com.liu.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liu.dto.GoodsDto;
import com.liu.entity.Goods;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GoodsDao extends BaseMapper<Goods> {
    /** 动态查询&&查询所有商品*/
    List<GoodsDto> list(@Param("tid") int tid, @Param("name") String name);

    List<GoodsDto> queryDetail(@Param("tid") int tid,@Param("gid") int gid);
    /**修改状态*/
    @Update("update t_goods set flag=#{flag} where id = #{gid}")
    int updateFlag(@Param("gid") int gid, @Param("flag") int flag);
    /**修改商品库存
     * 数据 库的互斥锁,stock>=#{num}*/
    @Update("update t_goods set stock = stock-#{num} where id=#{id} and stock>=#{num}")
    int updateStock(@Param("id") int id,@Param("num") int num);
}
